home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-03 | 5.0 KB | 174 lines | [TEXT/MPS ] |
- // UDragDropBehavior.cp
- // Copyright © 1994-96 by Apple Computer, Inc. All rights reserved.
-
- #ifndef __UDRAGDROPBEHAVIOR__
- #include "UDragDropBehavior.h"
- #endif
-
- // MacApp
-
- #ifndef __UCOREGLOBALS__
- #include "UCoreGlobals.h"
- #endif
-
- #ifndef __UMACAPPGLOBALS__
- #include "UMacAppGlobals.h"
- #endif
-
- #ifndef __USTREAM__
- #include "UStream.h"
- #endif
-
- #ifndef __UVIEW__
- #include "UView.h"
- #endif
-
- //========================================================================================
- // GLOBAL Procedures
- //========================================================================================
- #undef Inherited
-
- //========================================================================================
- // CLASS TDragDropBehavior
- //========================================================================================
- #undef Inherited
- #define Inherited TBehavior
-
- #pragma segment MADragRes
- MA_DEFINE_CLASS_M1(TDragDropBehavior, Inherited);
-
- //----------------------------------------------------------------------------------------
- // TDragDropBehavior constructor
- //----------------------------------------------------------------------------------------
- #pragma segment MADragNonRes
-
- TDragDropBehavior::TDragDropBehavior(void)
- {
- fDraggable = FALSE;
- fDroppable = FALSE;
- fDragMoveDeterminer = kNeverMove;
- fDragMoveFamily = kNoIdentifier;
- } // TDragDropBehavior
-
- //----------------------------------------------------------------------------------------
- // TDragDropBehavior destructor
- //----------------------------------------------------------------------------------------
- #pragma segment MADestructorRes
-
- TDragDropBehavior::~TDragDropBehavior()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // TDragDropBehavior::IDragDropBehavior
- //----------------------------------------------------------------------------------------
- #pragma segment MAOpen
-
- void TDragDropBehavior::IDragDropBehavior( IDType itsIdentifier,
- Boolean draggable,
- Boolean droppable,
- short dragMoveDeterminer,
- IDType dragMoveFamily)
- {
- this->IBehavior(itsIdentifier);
-
- fDraggable = draggable;
- fDroppable = droppable;
-
- fDragMoveDeterminer = dragMoveDeterminer;
- fDragMoveFamily = dragMoveFamily;
- } // TDragDropBehavior::IDragBehavior
-
- //----------------------------------------------------------------------------------------
- // TDragDropBehavior::ReadFrom
- //----------------------------------------------------------------------------------------
- #pragma segment MAReadResource
-
- void TDragDropBehavior::ReadFrom(TStream* aStream)
- {
- Inherited::ReadFrom(aStream);
-
- fDraggable = aStream->ReadBoolean();
- fDroppable = aStream->ReadBoolean();
- fDragMoveDeterminer = aStream->ReadInteger();
- fDragMoveFamily = aStream->ReadIDType();
- } // TDragDropBehavior::ReadFrom
-
-
- //----------------------------------------------------------------------------------------
- // TDragDropBehavior::WriteTo
- //----------------------------------------------------------------------------------------
- #pragma segment MAWriteResource
-
- void TDragDropBehavior::WriteTo(TStream* aStream)
- {
- Inherited::WriteTo(aStream);
-
- #if qDrag
- // read drag data out of the owner, since the values in the behavior may not be
- // current
- {
- TView *ownerView = (TView *)fOwner;
-
- fDraggable = ownerView->GetDraggable();
- fDroppable = ownerView->GetDroppable();
- fDragMoveDeterminer = ownerView->GetDragMoveDeterminer();
- fDragMoveFamily = ownerView->GetDragMoveFamily();
- }
- #endif // qDrag
-
- aStream->WriteBoolean(fDraggable);
- aStream->WriteBoolean(fDroppable);
- aStream->WriteInteger(fDragMoveDeterminer);
- aStream->WriteIDType(fDragMoveFamily);
- }
-
- //----------------------------------------------------------------------------------------
- // TDragDropBehavior::SetOwner
- //----------------------------------------------------------------------------------------
- #pragma segment MAOpen
-
- void TDragDropBehavior::SetOwner(TEventHandler* itsOwner)
- {
- Inherited::SetOwner(itsOwner);
-
- #if qDrag
- #if qDebug
- // verify that the owner is a TView
-
- if (itsOwner && !itsOwner->DescendsFrom(TView::GetClassDescStatic()))
- {
- ProgramBreak("###A TDragDropBehavior is attached to a non-view object");
- return;
- }
- #endif // qDebug
-
- // set data in the owner view
- if (itsOwner)
- {
- TView *ownerView = (TView *)itsOwner;
-
- ownerView->SetDraggable(fDraggable);
- ownerView->SetDroppable(fDroppable);
- ownerView->SetDragMoveDeterminer(fDragMoveDeterminer);
- ownerView->SetDragMoveFamily(fDragMoveFamily);
- }
- #endif // qDrag
-
- } // TDragDropBehavior::SetOwner
-
- //----------------------------------------------------------------------------------------
- // TDragDropBehavior::GetStandardSignature:
- //----------------------------------------------------------------------------------------
- #pragma segment MAWriteResource
-
- IDType TDragDropBehavior::GetStandardSignature()
- {
- return kDragDropBehavior;
- } // TDragDropBehavior::GetStandardSignature
-
- //----------------------------------------------------------------------------------------
- // End of UDragDropBehavior.cp
-
- #pragma segment Inline
-